/*
 *  RingerFSClientServer.h
 *  MetaThrift
 *
 *  Created by Ian Pye on 3/25/08.
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
 *
 */

#ifndef RINGER_CLIENT_SERVER_HEADER
#define RINGER_CLIENT_SERVER_HEADER 1

namespace ringer{
  
  class RingerFSClientServerHandler : virtual public RingerMetaServerIf {
  public:
    
    RingerFSClientServerHandler(); 
    ~RingerFSClientServerHandler();
    
    // auth methods
    // Check some permits.
    bool can_read(const rpath_t& path, const UserInfo& userInfo){ 
      return ringer_client_get_read(path.c_str(), userInfo);
    }
    // Check some permits.
    bool can_write(const rpath_t& path, const UserInfo& userInfo){  
      return ringer_client_get_write(path.c_str(), userInfo); 
    }
    
    // Server Methods
    void get_block(RingerBlock& _return, const rpath_t& path, const UserInfo& userInfo, const int32_t offset, const int32_t length);
    void send_block(const UserInfo& host, const rpath_t& path, const int32_t offset, const int32_t length);
    void accept_block(const ringer::RingerBlock&, const ringer::rpath_t&, int32_t, 
                      int32_t, const UserInfo& userInfo);
    
    
    // The rest
    int32_t ping();  
    int32_t add(const int32_t num1, const int32_t num2);
    void get(RNode& _return, const rpath_t& path, const UserInfo& userInfo);
    void put(const RNode& node, const UserInfo& userInfo);
    void remove(const rpath_t& path, const UserInfo& userInfo);
    bool get_read(const rpath_t& path, const UserInfo& userInfo);
    void end_read(const rpath_t& path, const UserInfo& userInfo);
    bool get_write(const rpath_t& path, const UserInfo& userInfo);
    void end_write(const rpath_t& path, const UserInfo& userInfo);
    // Tell us we have a kid.
    void connect_parent(const host_t& child_info);
    // Tell us the kid is going away.
    void disconnect_parent(const host_t& child_info);
    // Returns the owner info for the given path.
    void get_mds_owner(host_t& _return, const rpath_t& path);
    // takes word of an rnode being added below.
    void alert_parent_of_rnode(const rpath_t& path, const host_t& owner_info);
    void alert_parent_of_removed_rnode(const rpath_t& path);
    void connect_mds(const UserInfo& ui){ }
    void disconnect_mds(const UserInfo& ui){ }
    void update_hosts(set<string>& _ret){ }
    void search(std::set<rpath_t> & _return, const RingerSearch& search){}
    void get_mds_keyholder(host_t& _return, const rkeyword_t& keyword){}
    void publish_mds_keyholder(const rkeyword_t& keyword, const host_t& keyholder){}
    void relinquish_mds_keyholder(const rkeyword_t& keyword, const host_t& keyholder){}
    void alert_tagged_file(const rpath_t& path, const rkeyword_t& keyword){}

    
  }; // end RingerFSClientServerHandler
  
} // end ringer namespace
#endif // RINGER_CLIENT_SERVER_HEADER
